﻿// Action script...

// [onClipEvent of sprite 180 in frame 1]
onClipEvent (construct)
{
    label = "";
    labelPlacement = "right";
    selected = false;
}

// [Action in Frame 1]
function inv(mc)
{
    mc._visible = false;
} // End of the function
stop ();
inv(fillform);
inv(retCode);
inv(blablabla);
status_txt.text = "Fields marked with * is required.";
stop ();

function checkemail(email)
{
    if (email.indexOf("@") != -1 && email.indexOf(".") != -1 && email.length > 5)
    {
        return (true);
    }
    else
    {
        return (false);
    } // end else if
} // End of the function
function checkform()
{
    trace ("check form");
    if (name_txt.text.length == 0)
    {
        status_txt.text = "Type-in your name please.";
        Selection.setFocus(name_txt);
    }
    else if (email_txt.text.length == 0)
    {
        status_txt.text = "";
        Selection.setFocus(email_txt);
    }
    else if (!checkemail(email_txt.text))
    {
        status_txt.text = "Your email address is required.";
        Selection.setFocus(email_txt);
    }
    else if (message_txt.text.length == 0)
    {
        status_txt.text = "Whats your inquiry?";
        Selection.setFocus(message_txt);
    }
    else
    {
        sentform();
    } // end else if
} // End of the function
function sentform()
{
    status_txt.text = "Sending...";
    savedata();
} // End of the function
function savedata()
{
    loadLV = new LoadVars();
    loadLV.onLoad = function (success)
    {
        trace ("return_code: " + loadLV.return_code);
        if (success == true)
        {
            trace ("loadLV.success: " + success);
            if (loadLV.return_code == 1)
            {
                status_txt.text = "Your inquiry has been sent!";
                Selection.setFocus(name_txt);
                name_txt.text = "";
                email_txt.text = "";
                drop_mc.country_txt.text = "";
                message_txt.text = "";
                how_txt.text = "";
                join_chk.value = false;
                chk = 0;
                _root.country_id = undefined;
                gotoAndStop(2);
            }
            else
            {
                status_txt.text = "Your inquiry has not been sent, try again later.";
            } // end if
        } // end else if
    };
    if (join_chk.value == true)
    {
        chk = 1;
    } // end if
    sendLV = new LoadVars();
    sendLV.full_name = name_txt.text;
    sendLV.email = email_txt.text;
    sendLV.country = _root.country_id;
    sendLV.message = message_txt.text;
    sendLV.hear_about = how_txt.text;
    sendLV.join_mail = chk;
    if (drop_mc.country_txt.text != "Vietnam")
    {
        sendLV.lang = "1";
    } // end if
    sendLV.sendAndLoad(_global.mainPath + "contact_process.php", loadLV);
} // End of the function
stop ();
if (_global.mainPath == undefined)
{
    _global.mainPath = "http://saigon.whodigital.com:205/";
} // end if
name_txt.tabIndex = 1;
email_txt.tabIndex = 2;
message_txt.tabIndex = 3;
var keyListener = new Object();
keyListener.onKeyDown = function ()
{
    if (Key.getCode() == 13)
    {
        checkform();
    } // end if
};
Key.addListener(keyListener);
sendbtn_mc.onRelease = function ()
{
    checkform();
};
btnCancel.onRelease = function ()
{
    name_txt.text = "";
    email_txt.text = "";
    drop_mc.country_txt.text = "";
    message_txt.text = "";
    how_txt.text = "";
    join_chk.value = false;
    chk = 0;
    _root.loadPop(this._parent, 0);
};
Selection.setFocus(name_txt);
name_txt.text = "";
email_txt.text = "";
drop_mc.country_txt.text = "";
message_txt.text = "";
how_txt.text = "";
join_chk.value = false;
_root.country_id = undefined;
chk = 0;
